﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using proRFID_DiemDanh.Chung;
using System.Data;
using System.Data.SqlClient;

namespace proRFID_DiemDanh.PhongHoc
{
    public class mdPhongHoc
    {
        public static DataTable PhongHoc_Insert(string TenPhong)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_PhongHoc_Insert", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@TenPhong", TenPhong);
            
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }

        public static DataTable PhongHoc_Select(int MaPhong)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_PhongHoc_Select", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MaPhong", MaPhong);
            
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }

        public static DataTable PhongHoc_Delete(int MaPhong)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_PhongHoc_Delete", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@MaPhong", MaPhong);

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }
    }
}